import { PilotTime } from "../model/pilot.time";

export class ComponentInfoModel {
    public componentKey: string;
    public componentType: string;
    public componentName: string;
    public isBackup?: boolean;
    public appName?: string;
    public userName: string;
    public parentKey: string;
    public isDefault?: boolean;
    public hasDataFlag?: boolean;
    public data: string;
    public createdTime: PilotTime;
    public updatedTime: PilotTime;
    public hostName: string;
    public deleteFlag?: boolean;
    private classId: number;

    public static defaultFactory = (): ComponentInfoModel => {
        let componentKey = +new Date();
        let iPComponentInfoBO = {
            classId: 225,
            componentKey: +new Date(),
            componentType: componentKey,
            componentName: '',
            userName: '',
            parentKey: componentKey,
            data: '',
            hostName: +new Date(),
            createdTime: PilotTime.createPTime(),
            updatedTime: PilotTime.createPTime(),
            isBackup: false,
            isDefault: true,
            hasDataFlag: true,
            deleteFlag: false,
        };

        return new ComponentInfoModel(iPComponentInfoBO);
    }


    constructor(private _iPComponentInfoBO: any) {
        this.initializeModel();
    }

    get iPComponentInfoBO(): any {
        return this._iPComponentInfoBO;
    }

    private initializeModel(): void {
        this.componentKey = this._iPComponentInfoBO.componentKey;
        this.componentType = this._iPComponentInfoBO.componentType;
        this.componentName = this._iPComponentInfoBO.componentName;
        this.isBackup = this._iPComponentInfoBO.isBackup;
        this.appName = this._iPComponentInfoBO.appName || '';
        this.userName = this._iPComponentInfoBO.userName || '';
        this.parentKey = this._iPComponentInfoBO.parentKey;
        this.isDefault = this._iPComponentInfoBO.isDefault;
        this.hasDataFlag = this._iPComponentInfoBO.hasDataFlag;
        this.data = this._iPComponentInfoBO.data;
        this.createdTime = this._iPComponentInfoBO.createdTime;
        this.updatedTime = this._iPComponentInfoBO.updatedTime;
        this.hostName = this._iPComponentInfoBO.hostName || '';
        this.deleteFlag = this._iPComponentInfoBO.deleteFlag;
        this.classId = this._iPComponentInfoBO.classId || 225;
    }
}